﻿using System;
using System.Web.Mvc;
using MbUnit.Framework;
using Netkk.Common.Models;
using Netkk.Library.Repositories;
using Netkk.Library.Services;
using Netkk.Library.Validation;

namespace Netkk.Tests.Roles
{
    [TestFixture]
    public class RolesTest
    {
        private IRoleService roleService;

        [SetUp]
        public void Startup()
        {
            ModelStateDictionary modelStateDictionary = new ModelStateDictionary();
            IValidationDictionary validationDictionary = new ModelStateWrapper(modelStateDictionary);
            roleService = new RoleService(validationDictionary, new RoleRepository());
        }

        [TearDown]
        public void Shutdown()
        {
        }

        [Test]
        [Row("{42b85ce0-03f4-4f69-847e-d0412734a7a9}")]
        [Row("{52296b22-c5b8-4894-b628-bb0269631bf6}")]
        [Row("{6010b21c-b828-486e-94d1-f621caf0f9bc}")]
        public void Schould_Return_A_Valid_Role_From_A_Given_Id(string guid)
        {
            UserRole role = roleService.GetRoleById(new Guid(guid));

            Assert.IsNotNull(role);
        }

        [Test]
        [Row("{77777777-03f4-4f69-847e-d0412734a7a9}")]
        [Row("{52296b22-c5b8-4894-b628-777777777777}")]
        [Row("{6010b21c-7777-7777-7777-f621caf0f9bc}")]
        public void Schould_Not_Return_A_Valid_Role_From_A_Given_Id(string guid)
        {
            UserRole role = roleService.GetRoleById(new Guid(guid));

            Assert.IsNull(role);
        }
    }
}
